import moment from 'moment'
export default {
  namespaced: true,
  state: {
    ruleForm: {
      movieName: '',
      poster: '',
      director: '', // 导演
      actor: '', // 演员
      long: '',
      language: '',
      type: '',
      publicDate: '',
      intro: ''
    },
    isDialog: false,
    isAdd: true
  },
  mutations: {
    changeIsDialog (state, layload) {
      state.isDialog = layload
    },
    changeTime (state) {
      state.ruleForm.publicDate = moment(state.public_date).format('YYYY-MM-DD')
    },
    changeRuleForm (state, layload) {
      state.ruleForm = layload
    },
    changeIsAdd (state, layload) {
      state.isAdd = layload
    }
  },
  actions: {
    // 显示弹框
    changeIsDialog ({ commit }, layload) {
      commit('changeIsDialog', layload)
    },
    // 处理时间格式
    changeTime ({ commit }) {
      commit('changeTime')
    },
    // 修改form
    changeRuleForm ({ commit }, layload) {
      commit('changeRuleForm', layload)
    },
    // 是否为添加
    changeIsAdd ({ commit }, layload) {
      commit('changeIsAdd', layload)
    }
  }
}
